var startVal = 0;
var endVal = 11;

(function () {
    YAHOO.namespace('example');

    var Dom = YAHOO.util.Dom;

    // Slider has a range of 200 pixels
    var range = 110;

    // No ticks for this example
    var tickSize = 10;

    // We'll set a minimum distance the thumbs can be from one another
    var minThumbDistance = 10;

    // Initial values for the thumbs
    var initValues = [0,110];

    var cf = 900/(range - 20);

    // Set up a function to convert the min and max values into something useful
    var convert = function (val) {
        return Math.round(val * cf + 100);
    };

    // Slider set up is done when the DOM is ready
    YAHOO.util.Event.onDOMReady(function () {
        var demo_bg = Dom.get("demo_bg"),
            info    = Dom.get("demo_info"),
            from    = Dom.get("demo_from"),
            to      = Dom.get("demo_to");

        var slider = YAHOO.widget.Slider.getHorizDualSlider(demo_bg,
            "demo_min_thumb", "demo_max_thumb",
            range, tickSize, initValues);

        slider.minRange = minThumbDistance;
        
        var updateUI = function () {
            var min = convert(slider.minVal),
                max = convert(slider.maxVal - 20);

            Dom.get("lv").innerHTML = (slider.minVal) / 10;
            Dom.get("hv").innerHTML = (slider.maxVal) / 10;
        };
        
        
        var changeUI = function () {
            var min = convert(slider.minVal),
                max = convert(slider.maxVal - 20);

            startVal = (slider.minVal) / 10;
            endVal   = (slider.maxVal) / 10;
            
            
            var result = TrimPath.processDOMTemplate("fund_list", data);
            document.getElementById("listTable").innerHTML = result;
        };

        // Subscribe to the dual thumb slider's change and ready events to
        // report the state.
        slider.subscribe('ready', updateUI);
        slider.subscribe('change', updateUI);
        slider.subscribe('slideEnd', changeUI);
        
        YAHOO.example.slider = slider;
    });
})();